#!/bin/bash
DAPREFIX=/home/kharn/bin

if [ ! -e "./udpmon_extra-1.2.6.tar.gz" ]
then
wget http://www.hep.man.ac.uk/u/rich/Tools_Software/udpmon/udpmon_extra-1.2.6.tar.gz
fi
if [ ! -e "./libhj-4.2.6.tar.gz" ]
then
wget http://www.hep.man.ac.uk/u/rich/Tools_Software/libhj/libhj-4.2.6.tar.gz
fi
tar -xvvzf udpmon_extra-1.2.6.tar.gz
tar -xvvzf libhj-4.2.6.tar.gz
cd libhj-4.2.6/
./configure --prefix=$DAPREFIX
make clean
if [ $? -eq 2]
then
  sed -i.bak -e '/^dnl\ SUBDIRS/d' Makefile
  make clean
fi
make install
cd ../udpmon_extra-1.2.6/
./configure --prefix=$DAPREFIX --with-hj-location=$DAPREFIX
make clean
make
make install
echo "cleaning up"
echo $PATH|grep /usr/sbin
if [ ! $? -eq 0 ]
then
  export PATH=$PATH:DAPREFIX
  echo "Exported path only to local shell. For longer use, change your"
  echo "PATH-variable to hold also $DAPREFIXnot default on some distros"
fi
cd ..
rm libhj-4.2.6.tar.gz
rm udpmon_extra-1.2.6.tar.gz


